package com.exam.dao;

import java.sql.SQLException;
import com.exam.model.SettingModel;

/**
 * 处理系统设置参数
 * @author 维康
 *
 */
public class SettingDao extends BaseDao {
	
	/**
	 * 将系统设置存库
	 * @param setting
	 */
	public void updateSetting(SettingModel setting){
		String sql = "update ex_setting " +
						"set " +
							"pageSize="+setting.getPageSize()+"," +
							"isRegister="+setting.getIsRegister()+"," +
							"isOpenErrQue="+setting.getIsOpenErrQue()+"," +
							"copyright='"+setting.getCopyright()+"' " +
						" where id="+setting.getId();
		adu(sql);
	}
	
	/**
	 * 获取系统设置
	 * @return
	 * @throws SQLException
	 */
	public SettingModel getSystemSetting() throws SQLException{
		SettingModel setting = null;
		String sql = "select id,pageSize,isRegister,isOpenErrQue,copyright from ex_setting where id=1";
		res = query(sql);
		if(res.next()){
			setting = new SettingModel();
			setting.setId(res.getInt(1));
			setting.setPageSize(res.getInt(2));
			setting.setIsRegister(res.getInt(3));
			setting.setIsOpenErrQue(res.getInt(4));
			setting.setCopyright(res.getString(5));
		}
		closeDB();
		return setting;
	}
	
}
